<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<html:html>
<head>
<title><bean:message key="registration.title"/></title>
<link rel="stylesheet" href="<%=request.getContextPath() %>/default.css" type="text/css">
<html:base/>
</head>
<body>

<div id="header">
	<div id="logo">
		<h1>
			<html:img width="40" src="../images/EMPTY.GIF"/>
			<html:link page="/pages/home.jsp">Textbook Crossroads</html:link>
		</h1>
		<h2>Team 14 - LoneTree</h2>
	</div>
	<div id="menu">
		<ul>
		<ul>
			<li class="active">
			<logic:notPresent name="logged_in_user_in_session">
			<html:link page="/pages/home.jsp">Home</html:link>
			</logic:notPresent>
			<logic:present name="logged_in_user_in_session">
			<logic:equal value="false" name="logged_in_user_in_session" property="admin">
			<html:link action="/PrepForMyBooks">Dashboard</html:link>
			</logic:equal>
			<logic:equal value="true" name="logged_in_user_in_session" property="admin">
			<html:link page="/pages/admindashboard.jsp">Dashboard</html:link>
			</logic:equal>
			</logic:present>
			</li>
			<li><html:link page="/pages/books.jsp">Books</html:link></li>
			<li><html:link page="/pages/courses.jsp">Courses</html:link></li>
			<li><html:link page="/pages/about.jsp">About</html:link></li>
			<li class="logon">
			<logic:notPresent name="logged_in_user_in_session">
			<html:link page="/pages/logon.jsp">LogIn</html:link>
			</logic:notPresent>
			<logic:present name="logged_in_user_in_session">
			<html:link action="/logout">LogOut</html:link>
			</logic:present>
			</li>
		</ul>
		</ul>
	</div>
</div>

<logic:notPresent name="org.apache.struts.action.MESSAGE" scope="application">
  <font color="red">
    ERROR:  Application resources not loaded -- check servlet container
    logs for error messages.
  </font>
</logic:notPresent>

<div id="content">
	<div id="sidebar">
		<div id="categories">
			<div id="archives" class="boxed">
				<logic:notPresent name="logged_in_user_in_session">
						<h2>Contributors</h2>
				</logic:notPresent>
			
				<logic:present name="logged_in_user_in_session">			
					<logic:equal value="true" name="logged_in_user_in_session" property="admin">						
						<h2>Admin Actions</h2>										
					</logic:equal>
				
					<logic:equal value="false" name="logged_in_user_in_session" property="admin">
						<h2>MyActions</h2>						
					</logic:equal>
				</logic:present>
				
				<div class="content">
					<logic:notPresent name="logged_in_user_in_session">
						<ul>
							<li>Andrew Lee</li>
							<li>Bojan Martin</li>
							<li>Dimeji Omikunle</li>
							<li>Minghui Yu</li>
						</ul>
					</logic:notPresent>
					
					<logic:present name="logged_in_user_in_session">
						<ul>
							<logic:equal value="false" name="logged_in_user_in_session" property="admin">
					    		<li><html:link page="/PrepForMyBooks.do?manage=books">Manage MyBooks</html:link></li>
					            <li><html:link page="/PrepForMyBooks.do?manage=sections">Manage MySections</html:link></li>
					            <li><html:link action="/UpdateMyProfile">Update MyProfile</html:link></li>
							</logic:equal>
							
							<logic:equal value="true" name="logged_in_user_in_session" property="admin">
					    		<li><html:link href="bookadmin.jsp"><bean:message
					            key="adminbook.link"/></html:link></li>
					            
					            <li><html:link action="/AdminCourses"><bean:message
					            key="admincourses.link"/></html:link></li>
					            
					            <li><html:link action="/AdminAccounts"><bean:message
					            key="adminaccounts.link"/></html:link></li>
					            
					            <li><html:link action="/AdminComments"><bean:message
					            key="admincomments.link"/></html:link></li>
							</logic:equal>
						</ul>	
					</logic:present>
				</div>
			</div>
		</div>
	</div>

	<div id="posts">
		<div class="post">
			<logic:present name="update.action">
				<h2 class="title">Update Profile</h2>
				<div class="meta">
					<p class="date">Update your profile below:</p>
				</div>
			</logic:present>
			
			<logic:notPresent name="update.action">
				<h2 class="title"><bean:message key="registrationpage.heading"/></h2>
				<div class="meta">
					<p class="date">Fill out the form below to get started!</p>
				</div>
			</logic:notPresent>
			<div class="story">			
		<%
		String action;
		if(request.getAttribute("update.action") != null){
			action = "/UpdateMyProfileCommit";
		}
		else{
			action = "/Register";
		}
		%>
			<html:form action="<%=action %>" focus="username"
		           onsubmit="return validateLogonForm(this);">
		           
		    <table border="0" width="100%">
			<tr>
				<th align="right">
				<bean:message key="prompt.username"/>
				</th>
				<td align="left">
				<logic:present name="update.action">
		 		<html:text property="username" readonly="true"/>
			</logic:present>
			<logic:notPresent name="update.action">
				<html:text property="username" readonly="false"/>
			</logic:notPresent>
				
				</td>
				
			
			</tr>	
			
			<tr>
		            <th align="right">
		                <bean:message key="prompt.firstname"/>:
		            </th>
		            <td align="left">
		                <html:text property="firstName" size="20"/><br>
		            </td>
		        </tr>
			
			<tr>
		            <th align="right">
		                <bean:message key="prompt.lastname"/>:
		            </th>
		            <td align="left">
		                <html:text property="lastName" size="20"/><br>
		            </td>
		        </tr>
		        
		        <tr>
		            <th align="right">
		                <bean:message key="prompt.password" />:
		            </th>
		            <td align="left">
		                <html:password property="password" size="16" maxlength="18"
		                               redisplay="false"/><br>
		            </td>
		        </tr>
			
			<tr>
		            <th align="right">
		                <bean:message key="prompt.email"/>:
		            </th>
		            <td align="left">
		                <html:text property="email" size="16"/><br>
		            </td>
		        </tr>
		        
		        <tr>
		            <th align="right">
		                <bean:message key="prompt.address"/>:
		            </th>
		            <td align="left">
		                <html:text property="location" size="18"/><br>
			 	</td>          
		        </tr>
		        
		        <tr>
		        <th align="center">
		        	<td>
		        	<html:submit>
			        	<logic:present name="update.action">
			       	 		<bean:message key="update.button" />
			        	</logic:present>
			        	<logic:notPresent name="update.action">
			        		<bean:message key="register.button" />
			        	</logic:notPresent>
					</html:submit>
					<html:reset><bean:message key="clear.button" /></html:reset><br><br>
					  <logic:present name="exists">
		        <span style="color: #FF0000">Sorry, that username is taken.</span><br></logic:present>
		        <logic:present name="message"> <span style="color: #FF0000"><bean:write name="message" /></span></logic:present>
					</td>
				</th>
		        </tr>
			</table>
		        
			</html:form>
			</div>
		</div>
	</div>
</div>

	<div id="footer">
	<p id="copy">&copy;2007 LoneTree.</p>
	<p> (Andrew Lee | Bojan Martin | Dimeji Omikunle | Minghui Yu)</p>
</div>
</body>
</html:html>